#pragma once

#include <physics/Node.h>
#include <physics/NodeLoader.h>
#include <box2d/common/b2Math.h>
#include <physics/Types.h>

namespace physics
{

class Box: public Node
{
	PHYSICS_NODE_REGISTER(Box)

	friend class BoxLoader;

private:
	float width, height;

public:
	Box(World *world);
	Box(World *world, float width, float height, const Vector2 & center = Vector2(0.0f, 0.0f));

	virtual std::auto_ptr <xml::ObjectANSI> CreateLoader();

	virtual void SetCenter(const Vector2 & center);
	virtual Vector2 GetCenter() const;
	virtual Vector2 GetSize() const;
};


class BoxLoader: public NodeLoader
{
	Vector2 center;

	Box* GetNode() { return (Box*) node; }
	
protected:
	virtual bool on_attribute(xml::Provider *prov, const std::string &name, const std::string &value);
	virtual std::auto_ptr <b2Shape> CreateShape();

public:
	BoxLoader(Box *node): NodeLoader(node) {}
};

}	// namespace physics